function isNumber(sVal)
{
	var lRe= true;
	var nInt= 0;
	while (lRe && nInt<=sVal.length)
	{
		var cCA= sVal.charCodeAt(nInt);
		lRe= !(cCA<48 || cCA>57);		// not between 0..9
		nInt++;
	}
	return lRe;
}

function isChar(sVal)
{
	sVal= sVal.toUpperCase();
	var lRe= true;
	var nInt= 0;
	while (lRe && nInt<=sVal.length)
	{
		var cCA= sVal.charCodeAt(nInt);
		lRe= !(cCA<65 || cCA>90);		// not between A..Z
		nInt++;
	}
	return lRe;
}

function isSpecial(cChar, sSpecial)
{
	cChar= cChar.toUpperCase();
	sSpecial= sSpecial.toUpperCase();
	var lRe= false;
	var nInt= 0;
	while (!lRe && nInt<=sSpecial.length)
	{
		lRe= cChar.charCodeAt(0)==sSpecial.charCodeAt(nInt);		// not between sSpecial' value
		nInt++;
	}
	return lRe;
}

function inputMask(sMask,autoFocus)
{
	//sMask:
	//	- "L" : character
	//	- "9" : number
	//	- "#" : special characters ". "...

	var cChar= event.keyCode;
alert(cChar);
	if (autoFocus) {
		var objFocus= getObj(autoFocus);
		if (cChar==13 && objFocus) {objFocus.focus();objFocus.select();return};
	}
	if (cChar>=97 && cChar<=122) cChar-=32;

	sMask= sMask.toUpperCase();

	var sPlus= "";
	if (sMask.search("L")>=0) sPlus+= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	if (sMask.search("9")>=0) sPlus+= "0123456789";
	if (sMask.search("#")>=0) sPlus+= "`~!@#$%^&*()_-=|\'[];:<,.>?";
	sMask+= sPlus;

	var lRe= false;
	var nInt= 0;
	while (!lRe && nInt<=sMask.length)
	{
		lRe= cChar==sMask.charCodeAt(nInt);		// invalid key
		nInt++;
	}
	return lRe;
}

function zeroPad(num, places) {
	var zero = places - num.toString().length + 1;
	return Array(+(zero > 0 && zero)).join("0") + num;
}

function SetOBJ_UnLoadBind(){
$("[tag=datevn]").unbind();
$("[tag=datemmyy]").unbind();
}
function SetOBJ_LoadBind(){
    $("[tag=datevn]").attr('maxlength', 10);
    $("[tag=datevn]").css('width', 70);
    $("[tag=datevn]").datepicker({
		dateFormat: 'dd/mm/yy',
		changeMonth: true,
		changeYear: true,
		monthNamesShort: ["Thg 1","Thg 2","Thg 3","Thg 4","Thg 5","Thg 6","Thg 7","Thg 8","Thg 9","Thg 10","Thg 11","Thg 12"],
		dayNamesMin: ["T2","T3","T4","T5","T6","T7","<font color=red>CN</font>"],
		maxDate: '+1y', minDate: new Date(2010, 1 - 1, 1), 
		beforeShow: function(input, instance) {if ($(input).val()=="") $(input).datepicker('setDate', new Date());}
	});

	$("[tag=datevn]").mask('99/99/9999', { placeholder: ' ' });


	$("[tag=datemmyy]").attr('maxlength', 10);
	$("[tag=datemmyy]").css('width', 50);
	$("[tag=datemmyy]").focus(function() {
		$(".ui-datepicker-calendar").hide();
		$("#ui-datepicker-div").position({ my: "center top", at: "center bottom", of: $(this) });
	});

	$("[tag=datemmyy]").datepicker({
		dateFormat: 'mm/yy',
		changeMonth: true,
		changeYear: true,
		monthNamesShort: ["Thg 1","Thg 2","Thg 3","Thg 4","Thg 5","Thg 6","Thg 7","Thg 8","Thg 9","Thg 10","Thg 11","Thg 12"],
		maxDate: '+1y', minDate: new Date(2010, 1 - 1, 1), 
		beforeShow: function(input, instance) {
			var xVal=$(input).val();
			if (xVal=="") {
				$(input).datepicker('setDate', new Date());
			}
			else {
				$(input).datepicker('option', 'defaultDate', new Date( xVal.substr(3).valueOf() , xVal.substr(0,2).valueOf()-1 ));
				$(input).datepicker('setDate', new Date( xVal.substr(3).valueOf() , xVal.substr(0,2).valueOf()-1 ));
			}
		},
		onChangeMonthYear: function(year, month, inst) { this.value= (month<10?'0':'')+month+'-'+year; }
	});

	$("[tag=datemmyy]").mask('99/9999', { placeholder: ' ' });
}

function pageLoad() { SetOBJ_UnLoadBind(); SetOBJ_LoadBind(); }